﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Trotware.Resources;
using System.Windows.Media;

namespace Trotware.View
{
    public partial class MainPage : PhoneApplicationPage
    {
        //Variables
        public String login { get; set; }
        public String password { get; set; }
        public int cptError { get; set; }

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

        private void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            login = loginField.Text;
            password = passwordField.Password;

            if (login.Equals("")) {
                MessageBox.Show("Indiquer un identifiant");
                loginField.BorderBrush = new SolidColorBrush(Colors.Red);
                cptError ++;
            }
            if(password.Equals("")){
                MessageBox.Show("Indiquer un mot de passe ?");
                passwordField.BorderBrush = new SolidColorBrush(Colors.Red);
                cptError ++;
            }

            if(cptError == 0)
                NavigationService.Navigate(new Uri("/View/PivotMenu.xaml", UriKind.RelativeOrAbsolute));
        }

        private void loginField_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            loginField.BorderBrush = new SolidColorBrush(Colors.White);
        }

        private void passwordField_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            passwordField.BorderBrush = new SolidColorBrush(Colors.White);
        }



        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}